import Navs from './nav.json'
export const navs = Navs


const registerRoute = groups => {
  let routes = [];

  groups.map(group => {
    let groupItems = group.navItems;

    groupItems.map(nav => {
      try {
        routes.push({
          path: `${nav.path}`,
          component: resolve => require([`../pages${nav.path}.vue`], resolve),
          name: nav.title || nav.name,
          meta: {
            title: nav.title || nav.name,
            description: nav.description
          }
        });
      } catch (e) {
        nav.disabled = true;
      }
    });
  });
  return routes;
};

const routes = registerRoute(Navs)

routes.push({
  path: "/",
  component: resolve => require([`../pages/index.vue`], resolve),
  name: "index",
  meta: {
    title: "Feui",
    description: "weui1.x + vue2.x + nuim + webpack3.x = feui"
  }
});

routes.push({
  path: '*',
  component: resolve => require([`../pages/404.vue`], resolve),
  name: '404',
  meta: {
    title: '404 Not Found',
    description: ''
  }
})
export default routes
